<template>
  <div>
      <common-title title-name="项目信息" class="m-b10"/>
      <el-card shadow="never" class="d-flex flex-wrap card-box">
          <div class="card-item">
              <label>项目名称:</label>
              <span class="m-l5">{{ state.form.projectName }}</span>
          </div>
          <div class="card-item m-l20">
              <label>项目阶段:</label>
              <span class="m-l5">{{ state.form.projectStageName }}</span>
          </div>
          <div class="card-item m-l20">
              <label>实施时间:</label>
              <span class="m-l5">{{ state.form.planStartTime }}至{{ state.form.planEndTime }}</span>
          </div>
          <div class="card-item m-l20">
              <label>项目主责:</label>
              <span class="m-l5"> {{ state.form.responsibleDepartmentName }}/{{ state.form.responsibleUserName }}</span>
          </div>
          <div class="card-item m-l20">
              <label>任务名称:</label>
              <span class="m-l5"> {{ state.form.taskName }}</span>
          </div>
      </el-card>
  </div>

  <div class="m-t20">
      <common-title title-name="任务实施列表"/>
      <div>
          <div>
              <div></div>
              <div>
                  <el-button
                          size="small"
                          class="button_edit"
                          type="primary"
                          @click="projectProposal()"
                  >新增</el-button>
                  <el-button
                          size="small"
                          class="button_edit"
                          type="primary"
                          @click="deleteHandler()"
                  >删除</el-button
                  >
                  <el-button
                          size="small"
                          class="button_edit"
                          type="primary"
                          @click="upAllHandler()"
                  >上移</el-button
                  >
                  <el-button
                          size="small"
                          class="button_edit"
                          type="primary"
                          @click="downAllHandler()"
                  >下移</el-button
                  >
              </div>
          </div>
          <tableIndex
                  :tableData="state.tableData"
                  :tableHead="tableHead"
                  :isIndex="true"
                  :isSelection="true"
                  :isRadio="true"
                  :notSearch="true"
                  :fields="state.fields"
                  :height="500"
                  :isPaging="false"
                  @selectChange="selectChange"
          >
              <template #isOverdue="{ row }">
                  <AlarmClock
                          v-if="row.isOverdue === 1"
                          style="width: 1em; height: 1em; color: #fc7018"
                  />
                  <AlarmClock v-else style="width: 1em; height: 1em" />
              </template>

              <template #operate>
                  <el-table-column label="操作" width="500" align="center" fixed="right">
                      <template #default="{ row }">
                          <el-button
                                  v-if="
                  (row.status == -1 &&
                    row.auditStatus == 2 &&
                    row.isOverdue == 1) ||
                  (row.status == -1 &&
                    row.auditStatus == 0 &&
                    row.isOverdue == 0)
                "
                                  size="small"
                                  class="button_edit"
                                  type="primary"
                                  @click="addHandler(row)"
                          >{{ row.actionName }}</el-button
                          >

                          <el-button
                                  v-if="
                  row.status > 0 ||
                  (row.businessAuditStatus == 3 && row.status == -1)
                "
                                  size="small"
                                  class="button_edit"
                                  type="primary"
                                  @click="lookHandler(row)"
                          >查看结果</el-button
                          >
                          <el-button
                                  v-if="
                  row.isOverdue == 1 &&
                  row.status == -1 &&
                  (row.auditStatus == 0 || row.auditStatus == 3)
                "
                                  size="small"
                                  class="button_edit"
                                  type="primary"
                                  @click="anticipateHandler(row, '逾期上报')"
                          >逾期上报</el-button
                          >
                          <el-button
                              v-if="
                  row.isOverdue == 0 &&
                 ( row.status == -1 ||  row.status == 1)
                "
                              size="small"
                              class="button_edit"
                              type="primary"
                          >节点延期</el-button
                          >
                          <el-button
                                  v-if="row.auditStatus == 1 && row.status == -1"
                                  size="small"
                                  class="button_edit"
                                  type="primary"
                                  @click="anticipateHandler(row, '审核')"
                          >审核</el-button
                          >
                      </template>
                  </el-table-column>
              </template>

              <template #lcb="{ row }">
                  <svg-icon
                          v-if="row.milestoneStatus != -1"
                          style="cursor: pointer"
                          @click="svgHandler(row)"
                          icon-class="lcb_true"
                  />
                  <svg-icon
                          v-else
                          style="cursor: pointer"
                          @click="svgHandler(row)"
                          icon-class="lcb_false"
                  />
              </template>
          </tableIndex>
      </div>
  </div>

  <div class="m-t20">
      <common-title title-name="任务执行时间表"/>
      <!-- 甘特图 -->
      <div class="timeTask">
          <ProjectGantt2
                  v-if="state.dataList.length > 0 && dataListShow"
                  :ganttList="state.dataList"
                  type="任务执行"
          ></ProjectGantt2>
          <el-empty v-else description="暂无数据"></el-empty>
      </div>
  </div>

  <div class="m-t20">
      <common-title title-name="关联任务"/>
      <div class="m-b10">
          <span>前置任务</span>
      </div>
      <public-table
              :header-cell-style="{'background':'#F5F5F5'}"
              :page="page"
              :is-paging="false"
              :height="'200'"
              :tableData="state.preTaskList"
              :tableOption.sync="tableOption3"
      >
          <template #interestStatus="scope">
              <svg-icon
                      v-if="scope.row.interestStatus === 1"
                      icon-class="heart-active"
              />
              <svg-icon v-else icon-class="heart" />
          </template>
          <template #projectName="scope">
              <span style="color: #ff7b56;cursor: pointer;" @click="toDetails(scope.row)">{{scope.row.projectName}}</span>
          </template>
          <template #buttons="scope">
              <el-button size="small" type="primary" @click="toDetails(scope.row)" class="button_edit">详情</el-button>
          </template>
      </public-table>

      <div class="m-b10">
          <span>后置任务</span>
      </div>
      <public-table
              :header-cell-style="{'background':'#F5F5F5'}"
              :page="page2"
              :height="'200'"
              :is-paging="false"
              :tableData="state.backTaskList"
              :tableOption.sync="tableOption3"
      >
          <template #interestStatus="scope">
              <svg-icon
                      v-if="scope.row.interestStatus === 1"
                      icon-class="heart-active"
              />
              <svg-icon v-else icon-class="heart" />
          </template>
          <template #projectName="scope">
              <span style="color: #ff7b56;cursor: pointer;" @click="toDetails(scope.row)">{{scope.row.projectName}}</span>
          </template>
          <template #buttons="scope">
              <el-button size="small" type="primary" @click="toDetails(scope.row)" class="button_edit">详情</el-button>
          </template>
      </public-table>
  </div>


    <el-dialog
            v-model="state.centerDialogVisible"
            title="实施任务节点"
            width="30%"
            class="dialog dialogStyle"
            align-center
            @open="openDialog"
            @close="closeDialog"

    >
        <el-form
                ref="formRef"
                :model="formInline"
                :rules="rules"
                label-width="230"
        >
            <el-form-item label="所属任务名称">
                <el-input disabled v-model="state.form.taskName" placeholder="" />
            </el-form-item>
            <el-form-item label="任务节点(工作细项)名称" prop="itemName">
                <el-input v-model="formInline.itemName" placeholder="请输入任务节点名称" />
            </el-form-item>
            <el-form-item label="责任部门">
                <el-input
                        disabled
                        v-model="state.form.responsibleDepartmentName"
                        placeholder=""
                />
            </el-form-item>
            <el-form-item label="责任人" prop="responsibleUserId">
                <el-select v-model="formInline.responsibleUserId" placeholder="" disabled>
                    <el-option
                            v-for="item in state.projectTendersWayList"
                            :key="item.userId"
                            :label="item.userName"
                            :value="item.userId"
                    />
                </el-select>
            </el-form-item>
            <el-form-item label="节点实施行为" prop="actionId">
                <el-select v-model="formInline.actionId" placeholder="">
                    <el-option
                            v-for="item in state.implementationBehavior"
                            :key="item.actionId"
                            :label="item.actionName"
                            :value="item.actionId"
                    />
                </el-select>
            </el-form-item>
            <el-form-item label="节点计划实施期限" prop="planStartTime">
                <el-date-picker
                        v-model="formInline.planStartTime"
                        type="daterange"
                        range-separator="-"
                        start-placeholder="开始时间"
                        end-placeholder="结束时间"
                        value-format="YYYY-MM-DD HH:mm:ss"
                        size="large"
                />
            </el-form-item>
        </el-form>
        <template #footer>
        <span class="dialog-footer">
          <el-button @click="state.centerDialogVisible = false" class="button_cancel2">取消</el-button>
          <el-button type="primary" @click="submitFormInline" class="button_view"> 确定 </el-button>
        </span>
        </template>
    </el-dialog>

<!--  上传合同扫描件-->
    <contractDialog
            ref="contractdialog"
            @refreshList="projectTaskList"
    ></contractDialog>

<!--  上报实施成果-->
    <overDialog ref="overdialog" @refreshList="projectTaskList"></overDialog>

  <!-- 逾期上报 -->
    <anticipatLoading
            @projectTaskList="projectTaskList"
            ref="anticipatLoadingRef"
    ></anticipatLoading>

<!--    提交预算审批单-->
    <budget-approval-popup
        ref="budgetApprovalPopupRef"
        @onSuccess="projectTaskList"
    ></budget-approval-popup>
</template>

<script setup>
import {department, projectTaskApi} from "@/api/project";
import {onMounted, reactive, ref, watch} from "vue";
import {useRoute, useRouter} from "vue-router";
import { getURLhandler } from "@/views/constructionProjectManage/static/utools.js";
import {ElCard, ElDialog, ElForm, ElFormItem, ElDatePicker, ElMessage,ElEmpty} from "element-plus";
import CommonTitle from "@/components/CommonTitle.vue";
import TableIndex from "@/components/table/index.vue";
import {AlarmClock} from "@element-plus/icons-vue";
import {GetDateDiff} from "@/common/utils/GlobalUtils";
import {useStore} from "vuex";
import {projectTaskImplementation} from "@/api/taskImplementation";
import ProjectGantt2 from '@/views/tenderProjectManage/taskManage/components/gantt_chart.vue'
//实施成果
import OverDialog from '@/views/constructionProjectManage/mytobeDone/components/overDialog.vue'
// 逾期上报
import AnticipatLoading from '@/views/constructionProjectManage/projectImplementationTask/anticipatLoading.vue'
//合同扫描
import ContractDialog from '@/views/constructionProjectManage/mytobeDone/components/contractDialog.vue'
import PublicTable from "@/components/PublicTable.vue";
import BudgetApprovalPopup from "../components/budgetApprovalPopup.vue";

const route = useRoute();
const getProjectTaskId = getURLhandler(route.path).projectTaskId;


const page = reactive({
    total: 0,
    current: 1,
    size: 50
});
const page2 = reactive({
    total: 0,
    current: 1,
    size: 50
});
const tableOption3 = ref([
    { label: '重点关注', prop: 'interestStatus',slot:true },
    { label: '任务名称', prop: 'taskName' },
    { label: '所属项目', prop: 'projectName',slot: true },
    { label: '项目类型', prop: 'taskType' },
    { label: '计划开始时间', prop: 'planStartTime' },
    { label: '计划结束时间', prop: 'planEndTime' },
    { label: '计划工期', prop: 'workPeriod' },
    { label: '负责部门', prop: 'responsibleDepartmentName' },
    { label: '责任人', prop: 'responsibleUserName' },
    { label: '任务状态', prop: 'status',
        formatter: (val,row) => {
            let obj = {'-1':'未开始','-2':'待配置','0':'进行中','1':'完成','5':'已逾期'}
            if(row.exceedDays>0 && obj[val]){
                return obj[val]+'(已逾期)';
            }
            return obj[val] || '-';
        },
    },
    { label: '逾期天数', prop: 'exceedDays' },
    {
        label: '操作',
        slot: true,
        width: 130,
        overHidden:false,
        slotName: 'buttons',
        fixed: "right"
    }
]);

const state = reactive({
    preTaskList:[],
    backTaskList:[],

    implementationBehavior:[],
    projectTendersWayList:[],
    changeList:[],
    stage:{},
    tableData: [],
    dataList: [],
    centerDialogVisible: false,
    dateList: [],
    form: {
        taskName: '',
        planEndTime: '',
        planStartTime: '',
        responsibleDepartmentName: '',
        responsibleUserName: '',
        responsibleDepartmentId: ''
    },
    page: {
        page: 1,
        pageSize: 10,
        total: 0
    }
});

const dataListShow = ref(false)
let formInline = reactive({});
const rules = {
    itemName: [
        { required: true, message: '(工作细项)名称不能为空', trigger: 'blur' }
    ],
    actionId: [
        { required: true, message: '对应实施行为不能为空', trigger: 'blur' }
    ],
    planStartTime: [
        { required: true, message: '实施期限不能为空', trigger: 'blur' }
    ]
}

const tableHead = reactive([
    {
        label: '工作细项(任务节点)',
        prop: 'itemName',
        minWidth: 150,
    },
    {
        label: '实施行为类型',
        prop: 'actionName',
        minWidth: 150,
    },
    {
        label: '计划开始时间',
        prop: 'planStartTime',
        minWidth: 130,
    },
    {
        label: '计划结束时间',
        prop: 'planEndTime',
        minWidth: 130,
    },
    {
        label: '完成时间',
        prop: 'realEndTime',
        minWidth: 130,
    },
    {
        label: '延期次数',
        prop: 'delayNum',
    },
    {
        label: '逾期天数',
        prop: 'exceedDays',
    },
    {
        label: '节点状态',
        prop: 'status',
        minWidth: 130,
        formatter: (row) => { // -1未开始1进行中2已完成
           let obj = {'-1':'未开始','1':'进行中','2':'已完成','3':'停工','4':'停工'}
            if(row.exceedDays > 0 && obj[row.status]){
                return obj[row.status]+'(已逾期)';
            }
            return obj[row.status] || '-';
        }
    }
])

watch(
    () => state.dataList,
    (value) => {
        if (value.find((v) => v.realStartTime)) {
            dataListShow.value = true
        }
    }
)

/**
 * 查询项目信息
 */
const getInfo = (getProjectTaskId) => {
    projectTaskApi
        .getInfo(getProjectTaskId)
        .then((res) => {
            if (res.code === '200') {
                state.form = res.data
            }
        })
}

/**
 * 获取任务列表
 */
const projectTaskList = (getProjectTaskId) => {
    projectTaskApi
        .projectTaskList(getProjectTaskId || getURLhandler(route.path).projectTaskId)
        .then((res) => {
            if (res.code === '200' && res.data) {
                state.tableData = JSON.parse(JSON.stringify(res.data))
                state.dataList = res.data.map((v) => {
                    const obj = {
                        taskName: state.form.taskName,
                        text: v.itemName,
                        nodeName: v.itemName,
                        duration: GetDateDiff(v.planStartTime, v.planEndTime) + 1,
                        realStartTime: v.planStartTime,
                        realEndTime: v.planEndTime,
                        start_date: new Date(v.planStartTime)
                    }
                    return obj
                })
            }
        })
}

//获取实施行为列表
const getBehavior = () => {
    projectTaskApi.behaviorList().then((res) => {
        if (res.code === '200') {
            state.implementationBehavior = res.data
        }
    })
}

let store = useStore();
const openDialog = () => {
    formInline.responsibleUserId = store.state.user.userId;
    getUserByDepartment(state.form.responsibleDepartmentId);
}

const closeDialog = () => {
    formInline = reactive({
        itemName: '',
        planStartTime: [],
        responsibleUserId: '',
        actionId: '',
        responsibleDepartmentId: ''
    })
}

//通过部门ID获取人员
const getUserByDepartment = (id) => {
    department.getUserByDepartmentId(id).then((res) => {
        state.projectTendersWayList = res?.data || []
    })
}

/**
 * 新增节点
 */
const projectProposal = () => {
    state.centerDialogVisible = true;
}

/**
 * 删除
 */
const deleteHandler = () => {
    if (state.changeList.length === 0) {
        ElMessage.warning('请选择要删除的数据')
        return
    }
    projectTaskApi
        .delete({ itemIds: state.changeList.map((item) => item.itemId).join(',') })
        .then((res) => {
            if (res.code === '200') {
                ElMessage.success('操作成功')
                projectTaskList(getProjectTaskId)
            }
        })
}

/**
 * 新增任务节点确认
 */
const formRef = ref(null);
const submitFormInline = () => {
    formRef.value.validate((valid, fields) => {
        if (valid) {
            let params = {
               ...formInline,
                planStartTime:formInline.planStartTime[0],
                planEndTime:formInline.planStartTime[1],
                responsibleDepartmentId:state.form.responsibleDepartmentId,
                responsibleUserId:state.form.responsibleUserId,
                projectTaskId:getProjectTaskId,
            }
            projectTaskImplementation.createTaskItem(params).then(res=>{
               if(res.code === '200'){
                   ElMessage.success('新增成功!');
                   state.centerDialogVisible = false;
                   projectTaskList(getProjectTaskId);
               }else{
                   ElMessage.error('新增失败!');
                   state.centerDialogVisible = false;
               }
            });
        } else {
            console.log('error submit!', fields)
        }
    })
}

//选择复选框数据
const selectChange = (val) => {
    state.changeList = val
}

//表格数据批量上移
const upAllHandler = () => {
    if (state.changeList.length === 0) {
        ElMessage.warning('请选择需要上移的数据')
        return
    }
    let indexTaget = ''
    state.tableData.forEach((tableItem, i) => {
        state.changeList.forEach((item, index) => {
            if (item.itemId === tableItem.itemId) {
                indexTaget = i
            }
        })
    })
    upHandler(indexTaget)
}
const upHandler = (index) => {
    if (index === 0) {
        ElMessage.warning('已经是第一条数据了')
        return
    }
    const temp = state.tableData[index]
    state.tableData[index] = state.tableData[index - 1]
    state.tableData[index - 1] = temp
    sortUpdate()
}

//更新排序
const sortUpdate = () => {
    projectTaskApi
        .sortUpdate({
            itemIds: state.tableData.map((item) => item.itemId).join(',')
        })
        .then((res) => {
            if (res.code === '200') {
                ElMessage.success('操作成功')
                projectTaskList(getProjectTaskId)
            }
        })
}

//表格数据批量下移
const downAllHandler = () => {
    if (state.changeList.length === 0) {
        ElMessage.warning('请选择需要下移的数据')
        return
    }
    let indexTaget = ''
    state.tableData.forEach((tableItem, i) => {
        state.changeList.forEach((item, index) => {
            if (item.itemId === tableItem.itemId) {
                indexTaget = i
            }
        })
    })
    downHandler(indexTaget)
}
//表格数据下移动
const downHandler = (index) => {
    if (index === state.tableData.length - 1) {
        ElMessage.warning('已经是最后一条数据了')
        return
    }
    const temp = state.tableData[index]
    state.tableData[index] = state.tableData[index + 1]
    state.tableData[index + 1] = temp
    sortUpdate()
}

let router = useRouter();
const contractdialog = ref(null);
const overdialog = ref(null);
const anticipatLoadingRef = ref(null);
const budgetApprovalPopupRef = ref(null);
const addHandler = (row) => {
    switch (row.actionId) {
        case '10':
            let params = {
                projectName:state.form.projectName,
                projectStageName:state.form.projectStageName,
                taskName:state.form.taskName,
                projectId:state.form.projectId,
                projectTaskId:row.projectTaskId,
                itemId:row.itemId,
            }
            budgetApprovalPopupRef.value.openPopup(params);
            break;
        case '7':
            router.push({
                path: `/constructionProjectManage/projectSupervision/components/contract/projectId=${
                    state.form.projectId
                }&projectTaskId=${row.projectTaskId}&itemId=${
                    row.itemId
                }&isLook=${0}&type=0`
            })
            break
        case '6':
            router.push({
                path: `/constructionProjectManage/projectSupervision/components/service/projectId=${
                    state.form.projectId
                }&itemId=${row.itemId}&projectTaskId=${row.projectTaskId}&isLook=${0}`
            })
            break
        case '3':
            router.push({
                path: `/constructionProjectManage/projectSupervision/components/topic/projectId=${
                    state.form.projectId
                }&itemId=${row.itemId}&projectTaskId=${row.projectTaskId}&isLook=${0}`
            })
            // 发起招采需求议题请示
            break
        case '4':
            router.push({
                path: `/constructionProjectManage/projectSupervision/components/approve/projectId=${
                    state.form.projectId
                }&itemId=${row.itemId}&projectTaskId=${row.projectTaskId}&isLook=${0}`
            })

            break
        case '5':
            router.push({
                path: `/constructionProjectManage/projectImplementationTask/decisionIndex/projectId=${
                    state.form.projectId
                }&projectTaskId=${row.projectTaskId}&itemId=${row.itemId}&isLook=${0}`
            })

            break
        case '8':
            router.push({
                path: `/constructionProjectManage/projectImplementationTask/callForBids/projectId=${
                    state.form.projectId
                }&projectTaskId=${row.projectTaskId}&itemId=${
                    row.itemId
                }&isLook=${0}&type=1`
            })

            break
        case '9':
            contractdialog.value.state.dialogVisible = true
            contractdialog.value.state.businessId = row.businessId
            contractdialog.value.state.projectTaskId = row.projectTaskId
            contractdialog.value.state.type = 0
            contractdialog.value.state.itemId = row.itemId
            break
        case '1': // 上传实施成功
            overdialog.value.state.centerDialogVisible = true
            overdialog.value.state.businessId = row.businessId
            overdialog.value.state.projectTaskId = row.projectTaskId
            overdialog.value.state.type = 0
            overdialog.value.state.itemId = row.itemId
            break
        case '2':
            router.push({
                path: `/constructionProjectManage/projectImplementationTask/organizeAMeeting/projectId=${
                    state.form.projectId
                }&projectTaskId=${row.projectTaskId}&itemId=${row.itemId}&isLook=${0}`
            })
            break
    }
}

// 逾期上报
const anticipateHandler = (row, type) => {
    anticipatLoadingRef.value.open(row, type)
}

//里程碑
const svgHandler = (row) => {
    projectTaskApi.updateLcb({ id: row.itemId }).then((res) => {
        if (res.code === '200') {
            ElMessage.success('修改成功')
            projectTaskList()
        }
    })
}

/**
 * 查看结果
 * @param row
 */
const lookHandler = (row) => {
    console.log('row',row)
    switch (row.actionId) {
        case '10':
            let params = {
                projectId:state.form.projectId,
                taskId: getProjectTaskId,
                itemId:row.itemId,
            }
            projectTaskImplementation.getProjectBudgetControlForm(params).then(res=>{
                if(res.code==='200'){
                    window.open(res.data.routeUrl);
                }
            });
            break;
        case '7':
            //合同初稿
            router.push({
                path: `/constructionProjectManage/projectSupervision/components/contract/projectId=${
                    state.form.projectId
                }&itemId=${row.itemId}&projectTaskId=${row.projectTaskId}&itemId=${
                    row.itemId
                }&isLook=${1}&type=0`
            })
            break
        case '6':
            router.push({
                path: `/constructionProjectManage/projectSupervision/components/service/projectId=${
                    state.form.projectId
                }&itemId=${row.itemId}&projectTaskId=${row.projectTaskId}&isLook=${1}`
            })
            break
        case '3':
            router.push({
                path: `/constructionProjectManage/projectSupervision/components/topic/projectId=${
                    state.form.projectId
                }&itemId=${row.itemId}&projectTaskId=${row.projectTaskId}&isLook=${1}`
            })
            // 查看招采需求议题请示
            break
        case '4':
            router.push({
                path: `/constructionProjectManage/projectSupervision/components/approve/projectId=${
                    state.form.projectId
                }&itemId=${row.itemId}&projectTaskId=${row.projectTaskId}&isLook=${1}`
            })

            break
        case '5':
            router.push({
                path: `/constructionProjectManage/projectImplementationTask/decisionIndex/projectId=${
                    state.form.projectId
                }&projectTaskId=${row.projectTaskId}&itemId=${row.itemId}&isLook=${1}`
            })
            break
        case '8':
            router.push({
                path: `/constructionProjectManage/projectImplementationTask/callForBids/projectId=${
                    state.form.projectId
                }&projectTaskId=${row.projectTaskId}&itemId=${
                    row.itemId
                }&isLook=${1}&type=1`
            })
            break
        case '9':
            contractdialog.value.state.dialogVisible = true
            contractdialog.value.state.businessId = row.businessId
            contractdialog.value.state.projectTaskId = row.projectTaskId
            contractdialog.value.state.type = 1
            contractdialog.value.state.itemId = row.itemId
            break
        case '1':
            overdialog.value.state.centerDialogVisible = true
            overdialog.value.state.businessId = row.businessId
            overdialog.value.state.projectTaskId = row.projectTaskId
            overdialog.value.state.type = 1
            overdialog.value.state.itemId = row.itemId
            break
        case '2':
            router.push({
                path: `/constructionProjectManage/projectImplementationTask/organizeAMeeting/projectId=${
                    state.form.projectId
                }&projectTaskId=${row.projectTaskId}&itemId=${row.itemId}&isLook=${1}`
            })
          break;
    }
}

/**
 * 查询关联任务
 */
const getAssociatedTasks = (params) => {
    projectTaskImplementation.getAssociatedTasks(params).then(res=>{
      if(res.code==='200'){
          if(params.type===1){
              state.preTaskList = res.data;
          }
          if(params.type===2){
              state.backTaskList = res.data;
          }
      }
    });
}

/**
 * 跳转详情
 */
const toDetails = (row) => {
    router.push({
        path: `/constructionProjectManage/projectsPectaculars/pectaculars/type=${1}&id=${
            row?.projectId || ''
        }&name=${row?.projectName || ''}&projectType=${row?.type}&tabId=${row?.type}`
    })
}

onMounted(()=>{
    getInfo(getProjectTaskId);
    projectTaskList(getProjectTaskId);
    getBehavior();
    getAssociatedTasks({
        projectTaskId:getProjectTaskId,
        type:1
    });
    getAssociatedTasks({
        projectTaskId:getProjectTaskId,
        type:2
    });
});
</script>

<style lang="scss" scoped>
.card-box{
  width: 100%;
}

:deep(.card-box){
  .el-card__body{
    width: 100%;
    display: flex;
  }
}

.card-item{
  cursor: pointer;
  span{
    font-weight: 600;
  }
}
</style>
